
package testProxy;

import java.lang.reflect.Method;

import java.lang.reflect.InvocationHandler;

public class DynamicSubject implements InvocationHandler {
    private Object sub;

    public DynamicSubject(Object obj) {
        sub = obj;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long start = System.currentTimeMillis();
        Object obj = method.invoke(sub, args);
        System.out.println(method.getName() + " TIME: " + (System.currentTimeMillis() - start));
        return obj;
    }
}
